﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace The_LarX
{
    public class Renderer : Component
    {
        public Effect Effect;

        public Camera3D Camera;

        public Action BeforeTheSceneIsRendered;
        public Action AfterTheSceneIsRendered;

        public Renderer()
        {
            EngineSystem.Renderers.Add(this.Name, this);
            EngineSystem.RenderersList.Add(this);
            this.DeserializeFirst = true;
        }
        public Renderer(GameScreen g6)
            : base(g6)
        {
            EngineSystem.Renderers.Add(this.Name, this);
            EngineSystem.RenderersList.Add(this);
            this.DeserializeFirst = true;
        }

        public override void DisableComponent()
        {
            base.DisableComponent();

            EngineSystem.RenderersList.Remove(this);
            EngineSystem.Renderers.Remove(this.Name);
        }

        /// <summary>
        /// Stores the Actor, for posterior rendering
        /// </summary>
        public virtual void SubmitActor(Actor obj)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Removes the Actor from Rendering
        /// </summary>
        /// <param name="actor"></param>
        public virtual void RemoveActor(Actor obj)
        {
            throw new NotImplementedException();
        }

        public virtual float GetDistance(Vector3 position)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Stores the Light, for use with renderer
        /// </summary>
        /// <param name="Light"></param>
        public virtual void SubmitLight(object Light)
        {
        }

        /// <summary>
        /// Updates the Renderer, if there's anyting to be Updated
        /// </summary>
        public override void Update()
        {
        }
        /// <summary>
        /// Render the Actors, with the current Camera
        /// </summary>
        public virtual void RenderActors()
        {
            throw new NotImplementedException();
        }

        public override void Draw()
        {
            base.Draw();

            RenderActors();
        }

        public override void SerializeData()
        {
            base.SerializeData();
        }
        public override void DeserializeData()
        {
            EngineSystem.Renderers.Remove(this.name);

            base.DeserializeData();

            EngineSystem.Renderers.Add(this.Name, this);
        }
    }
}
